import JSEncrypt from "jsencrypt"

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANLCS+F25YA6HzzJjzYuU9AZmx6jly41dqmFSvr+rF1WVFLNXKbVcfCLVCqFV2b3QPbCn53ykT9MKnSj7narvg0CAwEAAQ=='

const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA0sJL4XblgDofPMmPNi5T0BmbHqOXLjV2qYVK+v6sXVZUUs1cptVx8ItUKoVXZvdA9sKfnfKRP0wqdKPudqu+DQIDAQABAkBkux5/TU9VYPIrIH7FO5EtZf+gvjl0iXMEhMOYgP4qwUifi/oDghHnR0gVfNhIUhZwVRI4b6hVHBE46r32rQ5hAiEA96tV2XFM3UXqOat0KU49dG/uAcxiLAUjLgJu+jn1b4kCIQDZ2SDy3QldtYOc2RNwCtyLPwkZLzwYANcZWpRKwIyVZQIhAI23IDx3tD+4zbmJ/cHU3x1NHqcwx8vgdKzS/6V2nJXhAiBy5iiQr7Bu8nu2UHAGGlR0RQ0BcX5akqbgwnuQabo8WQIgZMF9Ll++AdLk3M1bOQZv2vXTJb6ljcs9QR52cn8RTTc='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}